import Vue from 'vue'
import Router from 'vue-router'
import store from '../vuex/store'
import {getCookie} from "../utils/cookie.js"
import {messageHints} from "../utils/index.js"

/*公用引入**/
import Logins from '@/components/Login/index'
import Home from '@/components/Home/index'

/*客户管理*/
import customerInfo from '@/components/modules/customerManagement/customerInfo/index'

/*充值管理*/

/*消费管理*/

/*商品管理*/

/*订单管理*/

/*数据分析*/


 Vue.use(Router)
 const router = new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: Logins
    },
    {
      path: '/login',
      name: 'login',
      component: Logins
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      children: [
        {
          path: '/home/customerInfo',
          name: 'customerInfo',
          component: customerInfo,
        }
      ]
    }
  ]
})

// router.beforeEach((to, from, next) => {
// console.log(store.state,"store.state")
//  console.log(to.path,"to.path");
//  if (to.path != "/login" && to.path != "/home") {
//    const loginAready = store.state.login.userInfo[0].token //后台返回的路由权限数组
//    console.log(!!loginAready,"loginAready")
//    if (!!loginAready) {
//     next()
//    }else {
//     messageHints("请登录","warning")
//      next({
//        path: '/login'
//      });
//    }
//  } else {
//    next()
//  }

// })

export default router